import { request } from '@/network/request.js'
import Vue from 'vue'
import { VueJsonp } from 'vue-jsonp';
Vue.use(VueJsonp)
export const getluyou = (page) => {
    return request(
        {   
            url: '/product/pagination',
            params: { page: page, size: 10 },
        }
    )
}
//获取产品详情信息
export const getluyou1 = (id) => {
    return request(
        {
            url: '/product',
            params: { id: id },
        }
    )
}
//这样就会比较好维护 合并同类 如
//登入
export const getlogin = (data) => {
    return request({
        url: '/user/signin',
        method: 'post',
        data
    })
}
//获取个人用户信息
export const getpxx = () => {
    return request({
        url: '/user/info',


    })
}
//收藏
export const shouc = (id) => {
    return request({
        url: '/product_like/create',
        method: "post",
        data: { product_id: id }


    })
}
//取消收藏

export const delete1 = (id) => {
    return request({
        url: '/product_like/delete',

        params: { product_id: id }


    })
}
//加入购物车
export const addgouwuce1 = (data) => {
    return request({
        url: '/cart/update',
        method: 'post',
        data: data,
    })
}
//请求购物车清单
export const qqgwcqd = () => {
    return request({
        url: '/cart/all'
    })
}
//删除商品
export const scqdsp = (product_id) => {
    return request({
        url: '/cart/delete',
        params: product_id
    })
}
//获取用户信息
export const hqyhxx = () => {
    return request({
        url: '/user/info',

    })
}
export const GYDZ = "http://192.168.0.129:8360"
//新增地址请求
export const xinzengdizhiqq = (data) => {
    return request({
        url: '/user_address/create',
        method: 'post',
        data
    })
}
//修改地址请求
export const xiugaidizhi = (id, data) => {
    return request({
        url: '/user_address/update?id=' + id,
        method: 'post',
        data
    })
}
//删改地址请求
export const shanchudizhi = (id) => {
    return request({
        url: '/user_address/delete',

        params: { id }
    })
}
//下单/order/create
export const xiadan = (data, id) => {
    return request({
        url: 'order/create',
        method: 'post',
        data: { orderProductList: data, user_address_id: id }
    })
}
//获取订单/order
export const huoqudd = (id) => {
    return request({
        url:'/order',
        params:{id}

    })
}
//付款
export const fukuan = (id,data) => {
    return request({
        url: '/order/pay?order_id='+id,
        method:'post',
        data

    })
}
//获取订单我的订单
export const wodezongdingdan = (page) => {
    return request({
        url: '/order/pagination',
        page
    })
}
//获取我的收藏列表
export const wodeshouclist = () => {
    return request({
        url:'/product_like/all',
    })
}
//修改昵称
export const xiugainicheng = (nickname) => {
    return request({
        url: '/user/setting',
        method: 'post',
        data:{ nickname: nickname }
    })
}
//修改登录密码
export const xigaidenglumimaqq = (password,newPassword) => {
    return request({
        url: '/user/updatePassword',
        method: 'post',
        data:{password:password,newPassword:newPassword}
    })
}
//修改支付密码
export const xiugaipaymimaqq = (password,newPassword) => {
    return request({
        url: '/user/updatePayPassword',
        method: 'post',
        data:{password:password,newPassword:newPassword}
    })
        
}
//上传头像
export const shangctup = (data) => {
    return request({
        url: '/user/avatar',
        method: 'post',
        data
    })
}
//搜索商品
export const sousuosp = (key) => {
    return request({
        url: '/product/pagination',
        params:key
    })
}
//获取城市
export const huoqucshi = () => {
    return request({
        url: '/data/city',
       
    })
}
export const reqLocation = (latitude,longitude) => Vue.prototype.$jsonp('http://api.map.baidu.com/geocoder/v2/?ak=C93b5178d7a8ebdb830b9b557abce78b&callback=renderReverse&location='+latitude+','+longitude+'&output=json&pois=0')